package com.sop.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sop.model.PeopleInfo;
import com.sop.model.vo.PeopleInfoVo;
import com.sop.service.PeopleService;
import common.base.GridPage;

@Controller
@RequestMapping("/people")
public class PeopleController {

	@Autowired
	private PeopleService peopleService;
	
	@ResponseBody
	@RequestMapping("/getPeopleList")
	public List<PeopleInfo>  userList(){
		List<PeopleInfo> userList = peopleService.getPeopleList();
		return userList;
	}
	
	@ResponseBody
	@RequestMapping("/findPeople")
	public GridPage<PeopleInfo>  findPeople(PeopleInfoVo  peopleInfoVo){
		return  peopleService.findPagerBySearchVo(peopleInfoVo);
	}
	
	@ResponseBody
	@RequestMapping("/getPeople")
	public PeopleInfo  getPeople(Integer id){
		return peopleService.get(id);
	}
	
	@ResponseBody
	@RequestMapping("/add")
	public PeopleInfo  add(PeopleInfo info){
		PeopleInfo user = peopleService.add(info);
		return user;
	}
	
	@ResponseBody
	@RequestMapping("/update")
	public PeopleInfo  update(PeopleInfo info){
		PeopleInfo user = peopleService.update(info);
		return user;
	}
	
	@ResponseBody
	@RequestMapping("/delete")
	public boolean  delete(Integer id){
		 peopleService.delete(id);
		return true;
	}
}
